var t = getApp();

Page({
    data: {
        pluApiAll: {
            TeamPerformanceAward: {
                member: "plugin.performance.frontend.bonus.getMemberInfo",
                list: "plugin.performance.frontend.bonus.getList"
            },
            performanceNew: {
                member: "plugin.performance-new.frontend.bonus.getMemberInfo",
                list: "plugin.performance-new.frontend.bonus.getList"
            }
        },
        member: {},
        recordsList: [],
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        progressNum: 0
    },
    onLoad: function(t) {
        var a = t.plu ? "performanceNew" : "TeamPerformanceAward";
        this.data.pluApi = this.data.pluApiAll[a], this.getMember(), this.getData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    getMember: function() {
        var a = this, e = t.getNetAddresss(this.data.pluApi.member);
        t._getNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                if (1 == e.result) {
                    var s = Number(e.data.rest) > 0 ? parseInt(100 * (1 - Number(e.data.rest) / Number(e.data.rest_all))) : 100;
                    a.setData({
                        member: e.data,
                        progressNum: s
                    }), wx.setNavigationBarTitle({
                        title: e.data.plugin_name
                    });
                }
            }
        });
    },
    getData: function() {
        var a = this, e = t.getNetAddresss(this.data.pluApi.list);
        t._postNetWork({
            url: e,
            success: function(t) {
                var e = t.data;
                1 == e.result ? (a.data.isLoadMore = !0, a.data.total_page = e.data.list.last_page, 
                a.data.total_page || (a.data.total_page = 0), a.setData({
                    recordsList: e.data.list.data
                })) : wx.showToast({
                    title: e.msg
                });
            }
        });
    },
    _getMoreData: function() {
        var a = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page = this.data.page + 1;
            var e = t.getNetAddresss(this.data.pluApi.list);
            t._getNetWork({
                url: e,
                data: {
                    page: this.data.page
                },
                success: function(t) {
                    var e = t.data;
                    if (a.data.isLoadMore = !0, 1 == e.result) {
                        var s = e.data.list.data;
                        a.setData({
                            recordsList: a.data.recordsList.concat(s)
                        });
                    } else a.data.page = a.data.page - 1, a.data.isLoadMore = !1, wx.showToast({
                        title: e.msg
                    });
                }
            });
        }
    }
});